# Contributor: Carter Li <zhangsongcui@live.cn>
# Maintainer: fossdd <fossdd@pwned.life>
pkgname=fastfetch
pkgver=2.29.0
pkgrel=0
pkgdesc="Maintained, feature-rich and performance oriented, neofetch-like system information tool"
url="https://github.com/fastfetch-cli/fastfetch"
arch="all"
license="MIT"
depends="
	hwdata-pci
	"
makedepends="
	cmake samurai
	yyjson-dev
	yyjson-static
	vulkan-loader-dev
	libxcb-dev
	wayland-dev
	libdrm-dev
	dconf-dev
	imagemagick-dev
	chafa-dev
	zlib-dev
	dbus-dev
	mesa-dev
	opencl-dev
	xfconf-dev
	sqlite-dev
	pulseaudio-dev
	ddcutil-dev
	elfutils-dev
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/fastfetch-cli/fastfetch/archive/refs/tags/$pkgver.tar.gz"

prepare() {
	default_prepare

	rm -rf src/3rdparty/yyjson
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=Release \
		-DENABLE_SYSTEM_YYJSON=ON \
		-DENABLE_DIRECTX_HEADERS=OFF \
		-DPACKAGES_DISABLE_DPKG=ON \
		-DPACKAGES_DISABLE_EMERGE=ON \
		-DPACKAGES_DISABLE_EOPKG=ON \
		-DPACKAGES_DISABLE_GUIX=ON \
		-DPACKAGES_DISABLE_LINGLONG=ON \
		-DPACKAGES_DISABLE_LPKG=ON \
		-DPACKAGES_DISABLE_LPKGBUILD=ON \
		-DPACKAGES_DISABLE_NIX=ON \
		-DPACKAGES_DISABLE_OPKG=ON \
		-DPACKAGES_DISABLE_PACMAN=ON \
		-DPACKAGES_DISABLE_PACSTALL=ON \
		-DPACKAGES_DISABLE_PALUDIS=ON \
		-DPACKAGES_DISABLE_PKG=ON \
		-DPACKAGES_DISABLE_PKGTOOL=ON \
		-DPACKAGES_DISABLE_RPM=ON \
		-DPACKAGES_DISABLE_SORCERY=ON \
		-DPACKAGES_DISABLE_XBPS=ON \
		$crossopts
	cmake --build build --target fastfetch --target flashfetch
}

check() {
	build/fastfetch --list-features
	build/fastfetch -c presets/ci.jsonc
	build/fastfetch -c presets/ci.jsonc --format json
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
75e483c0ca2ad5455f64074ed922865298a889455af0ff5197fc82d77df71da6a3e1dac061f24fcce010dae00a02ee037777f09a9320b2a93d71b275d5475af8  fastfetch-2.29.0.tar.gz
"
